/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __933D3BFC_373A_4e6a_8AEF_3E489E04BC1E__
#define __933D3BFC_373A_4e6a_8AEF_3E489E04BC1E__

#include "../macro/head.h"
#include "../release/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_box
{
    class i_wstring;
    class i_string;
    class i_buf;
}

namespace xos
{
    // 
    // misc interface
    // 
    class i_misc : public i_release
    {
    protected:
        virtual ~i_misc(){}

    public:
        virtual int utf16_to_wchar( const char * lpszSrc, size_t tSrcSize, char * lpszDst, size_t tDstBufSize, size_t & DstSize ) = 0;
        virtual int wchar_to_utf16( const char * lpszSrc, size_t tSrcSize, char * lpszDst, size_t tDstBufSize, size_t & DstSize ) = 0;

        virtual int utf8_to_wchar( const char * lpszSrc, size_t tSrcSize, char * lpszDst, size_t tDstBufSize, size_t & DstSize ) = 0;
        virtual int wchar_to_utf8( const char * lpszSrc, size_t tSrcSize, char * lpszDst, size_t tDstBufSize, size_t & DstSize ) = 0;

        virtual int utf8_to_utf16( const char * lpszSrc, size_t tSrcSize, char * lpszDst, size_t tDstBufSize, size_t & DstSize ) = 0;
        virtual int utf16_to_utf8( const char * lpszSrc, size_t tSrcSize, char * lpszDst, size_t tDstBufSize, size_t & DstSize ) = 0;

        virtual int utf8_to_utf16( const xos_box::i_string * pSrc, xos_box::i_buf * pDstBuf ) = 0;
        virtual int utf16_to_utf8( xos_box::i_buf * pSrcBuf, xos_box::i_string * pDst ) = 0;

        virtual int utf8_to_wchar( const xos_box::i_string * pSrc, xos_box::i_wstring * pDst ) = 0;
        virtual int wchar_to_utf8( const xos_box::i_wstring * pSrc, xos_box::i_string * pDst ) = 0;

        // 
        // get process full file name
        // 
        virtual int get_process_file_full_name( char * pszFile, int nLen, int * pnLenNeeded ) = 0;
        virtual int get_process_file_full_name( xos_box::i_string * pStr ) = 0;

        // 
        // get process file path. not including '\\' or '/'
        // 
        virtual int get_process_path( char * pszPath, int nLen, int * pnLenNeeded ) = 0;
        virtual int get_process_path( xos_box::i_string * pStr ) = 0;

        // 
        // append path in all platform
        // 
        virtual int path_append( char * lpszPath, int nBufSize, const char * lpszAdder ) = 0;
        virtual int path_append( xos_box::i_string * pStr, xos_box::i_string * pAdder ) = 0;
        virtual int path_append( xos_box::i_string * pStr, const char * lpszAdder ) = 0;

        // 
        // real path
        // 
        virtual int real_path( const char * lpszPath, char * lpszRealPath, int nSize ) = 0;
        virtual int real_path( xos_box::i_string * pPath ) = 0;

        // 
        // create guid
        // 
        virtual int create_guid( char * lpszGuid ) = 0;

        // 
        // sleep 1 / 1000 second
        // 
        virtual int sleep( int nMilliseconds ) = 0;

        // 
        // output debuf info
        // 
        virtual int out_put_debug_string( const char * lpszInfo ) = 0;
        virtual int out_put_to_cmd( const char * lpszInfo ) = 0;
        virtual int trace( const char * lpszFormat, ... ) = 0;

        // 
        // get seconds from since 1970-1-1
        // 
        virtual uint64_t get_wall_second( uint64_t * lpWallSecond ) = 0;

        // 
        // sys method
        // 
        virtual uint64_t get_current_process_id() = 0;
        virtual uint64_t get_current_thread_id() = 0;
        virtual const char * platform() = 0;
        virtual bool can_hot_replace() = 0;
        virtual int get_cpu_num() = 0;
        virtual int ensure_memory_visibility() = 0;

        // 
        // aligned alloc & free
        // 
        virtual void* aligned_alloc( size_t size, size_t alignment ) = 0;
        virtual void aligned_free( void * ptr ) = 0;
    };
}

#endif // __933D3BFC_373A_4e6a_8AEF_3E489E04BC1E__
